package com.example.musicproject.Controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.common.pojo.musicimg;
import com.example.common.utils.R;
import com.example.service.ImgNameservice;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/tuku")
@Api(tags = "图片管理",value = "图片管理")
public class ImgNameController {

    @Autowired
    private ImgNameservice imgNameservice;

    @GetMapping("/tplist")
    @ApiOperation(value = "图片列表", notes = "图片列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "页码", required = true, dataType = "int", paramType = "query",example = "1"),
            @ApiImplicitParam(name = "pageSize", value = "每页数量", required = true, dataType = "int", paramType = "query",example = "10")
    })
    public R<Page<musicimg>> tukulist(int page, int pageSize){
        Page page1 = new Page(page,pageSize);
        Page page2 = imgNameservice.page(page1);
        return R.success(page2);
    }

    @GetMapping("/tuku/{tpId}")
    @ApiOperation(value = "图片详情", notes = "图片详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tpId", value = "图片id", required = true, dataType = "Long", paramType = "path",example = "1")
    })
    public R<musicimg> tukuselectId(@RequestParam("tpId") Long tpId){
        LambdaQueryWrapper<musicimg> wapper = new LambdaQueryWrapper<>();
        wapper.eq(musicimg::getId,tpId);
        musicimg one = imgNameservice.getOne(wapper);
        return R.success(one);
    }

}
